package myBinarySearch;

import java.util.Arrays;
import java.util.Comparator;

public class MyBinarySearch {
    public static void main(String[] args) {
        Integer[] srcArray = {1, 5, 15, 7, 9, 11, 13, 3};
        int des = 9;
        Arrays.sort(srcArray, new Comparator<>(){
            public int compare(Integer a,Integer b){
                return a-b;
            }
        });
        int index = Arrays.binarySearch(srcArray, des);
        if (index != -1) {
            System.out.println("元素 " + des + " 在新数组中的索引为: " + index);
        } else {
            System.out.println("数组中没有找到元素 " + des);
        }
    }
}
